package server;

import java.io.IOException;

/**
 * MyServlet
 * @author chenx
 * @date 2021/8/26-22:32
 */
public class MyServlet extends HttpServlet {

    @Override
    public void doGet(Request request, Response response) {
//        try {
//            System.out.println("=====休眠中=====");
//            Thread.sleep(100);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        String content = "<h1>MyServlet get</h1>";
        try {
            response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String content = "<h1>MyServlet post</h1>";
        try {
            response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void init() throws Exception {

    }

    @Override
    public void destory() throws Exception {

    }
}
